package cn.ilovese.collect.vo.task;

import cn.ilovese.collect.po.task.Task;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.NonNull;

import java.util.Date;

public class TaskVO {
    private Integer id;

    private Integer userId;

    private String taskname;

    private String description;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date deadline;

    private Integer total_num;

    private Integer need_num;

    private String type;

    private String environment;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getTaskName() {
        return taskname;
    }

    public void setTaskName(String taskName) {
        this.taskname = taskName == null ? null : taskName.trim();
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return deadline;
    }

    public void setEndTime(Date endTime) {
        this.deadline = endTime;
    }

    public Integer getTotalNumber() {
        return total_num;
    }

    public void setTotalNumber(Integer totalNumber) {
        this.total_num = totalNumber;
    }

    public Integer getNeedNumber() {
        return need_num;
    }

    public void setNeedNumber(Integer needNumber) {
        this.need_num = needNumber;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }

    public String getEnvironment() {
        return environment;
    }

    public void setEnvironment(String environment) {
        this.environment = environment == null ? null : environment.trim();
    }

    public TaskVO(@NonNull Task task){
        id=task.getId();
        userId=task.getUserId();
        taskname=task.getTaskName();
        description=task.getDescription();
        startTime = task.getStartTime();
        deadline = task.getEndTime();
        total_num = task.getTotalNumber();
        need_num  = task.getNeedNumber();
        type = task.getType();
        environment = task.getEnvironment();
    }

    public TaskVO(TaskFormVO task, Integer uid) {
        userId = uid;
        taskname=task.getTaskname();
        description=task.getDescription();
        startTime = new Date();
        deadline = task.getDeadline();
        total_num = need_num  = task.getNeed_num();
        type = task.getType();
        environment = task.getEnvironment();
    }
    public TaskVO(){

    }
}